/*
 * @Description: 
 * @Author: 姜暖阳
 * @Date: 2021-07-29 10:07:00
 * @LastEditTime: 2022-05-23 18:22:29
 * @LastEditors: 赵大壮
 * @Reference: 
 */
import router from "./index";
import store from "@/store";

// 1.登录权限，未登录则登录
// 2.页面权限，无权限则提示 v2.0:无权限则隐藏

router.beforeEach((to, from, next) => {
    console.log("from = ", from);
    console.log("to = ", to);
    // 1.未登录
    if (!store.state.user.isLogin() && to.name != 'login') {
        next({ path: '/login' });
        return;
    }
    if (store.state.user.isLogin() && to.name == 'login') {
        next({ path: '/' });
        return;
    }
    next();
})